import java.util.LinkedList;
import java.util.Queue;

/**
 * @author ZCR
 * @create 2025/9/9 22:29
 */
public class Solution255 {
    class MyStack {
        Queue<Integer> queue;

        public MyStack() {
            queue = new LinkedList<>();
        }
        public void push(int x) {
            queue.add(x);
            int size = queue.size();
            for (int i = 1; i < size; i++) {
                queue.add(queue.poll());
            }
        }

        public int pop() {
            if (queue.isEmpty()) {
                return -1;
            }
            return queue.poll();
        }

        public int top() {
            if (queue.isEmpty()) {
                return -1;
            }
            return queue.peek();
        }
        public boolean empty() {
            return queue.isEmpty();
        }
    }
}
